#!/usr/bin/env python3
# -*- coding: utf-8 -*-

from tkinter import *
import tkinter.messagebox as messagebox


class Application(Frame):
    def __init__(self, master=None):
        Frame.__init__(self, master)
        self.pack()
        self.createWidgets()
        self.winfo_width()

    def createWidgets(self):
        self.nameInput = Entry(self)
        self.nameInput.pack()
        self.helloButton = Button(self, text='Hello', command=self.hello)
        self.helloButton.pack()

        self.helloLabel = Label(self, text='Hello,world')
        self.helloLabel.pack()
        self.quiteButton = Button(self, text='退出', command=self.quit)
        self.quiteButton.pack()

    def hello(self):
        name = self.nameInput.get() or 'world'
        messagebox.showinfo('Message', 'Hello %s' % name)


app = Application()
app.master.title('Hello World')
app.mainloop()
